package jmine.tec.security.permission;

import java.io.Serializable;

import javax.security.auth.Subject;

/**
 * @author takeshi
 */
public interface PermissionChecker extends Serializable {

    /**
     * Verifica se o subject passado tem a permissao necessaria
     * 
     * @param subject {@link Subject}
     * @return boolean
     */
    boolean hasPermission(Subject subject);

    PermissionChecker NO_CHECK = new PermissionChecker() {

        public boolean hasPermission(Subject subject) {
            return true;
        }

        Object readResolve() {
            return NO_CHECK;
        }

    };

    PermissionChecker LOGIN_REQUIRED = new PermissionChecker() {

        public boolean hasPermission(Subject subject) {
            return subject != null;
        }
        

        Object readResolve() {
            return LOGIN_REQUIRED;
        }

    };

}
